package max.t;
import java.util.ArrayList;
// imports stuff to be used in drawview
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.*;
import android.view.View.*;

public class DrawViewno extends View implements OnTouchListener

{
	// creates ball called ball1 paint called paint and an array called pikachulist and a contexty called context all are variables
	private Ball ball1;
	private Paint paint;
	ArrayList<Ball> pikachulist;
	Context context; 
	
public DrawViewno(Context context) 
{
// because view is extended constructor called for view
// set focus: it can be added to touch part
// saves the context (r file and such) where things are getting drawn	
		super(context);
		setFocusable(true);
		pikachulist = new ArrayList<Ball>();
		this.context = context;
		
// first number is 50 for x value second number 50 for y value next two are floats for velocity, then radius then color	
		pikachulist.add(new Ball(200, 200, 3, 1, Color.BLUE,20,context, R.drawable.pikachu));
		setFocusableInTouchMode(true);
		this.setOnTouchListener(this);
		// TODO Auto-generated constructor stub
	}

@Override

public void onDraw(Canvas c)
{
  
// Creates a new one for i which is equal to the number of pikachus in pikachulist and increments creating bitmap
	for(int i=0; i<pikachulist.size(); i++)
	{
		ball1 = pikachulist.get(i);
		ball1.move(1,1, ball1);
		c.drawBitmap(ball1.getImage(),ball1.getx(), ball1.gety(), null);
	}
	
	invalidate();
}

public boolean onTouch(View v, MotionEvent event) {
	// TODO Auto-generated method stub
//	ball1.setX((int) event.getX());
//	ball1.setY((int) event.getY());
// on click pikachulist adds a new ball (pikachu with alkl of the properties listed) 
	pikachulist.add(new Ball((int) event.getX(), (int) event.getY(), 3, 10, Color.BLUE,20,context, R.drawable.pikachu ));
	return true;
}

}

